//var host = 'http://zhaoniuw.com:8080/findCows';

var detailedId = '';

detailedId = Cookie.getCookie('provideInfoId')

console.log(detailedId);

var urlType = '',
	dataType = '';
urlType = '/order/add/withProvide';

		//接口2.1.18
//这里不是传输进去的  而是

dataType = "purchaseInfoId=" + detailedId;

console.log(dataType)

askPostData(urlType)
function askPostData(num){
	console.log(num)
	$.ajax({
		url:host + num,
		type:"post",
		data:dataType,
		success:function(res){
			if(res.success == true){
//				console.log(res)  没有length
					//res为对象，没有
				console.log(res.data)

				$('#content>div').eq(0).empty();
				createDivOne(res.data);
				$('#content>div').eq(1).empty();
				createDivTwo(res.data);
			}else{
				//就是无数据则返回什么
				console.log('没有进入')
			}
		}
	});
}

function createDivOne(num){


	$('#content>div').eq(0).append('<p>求购详情</p><div class="content"><div><p>类别</p><p>'+ num.meatCategory +'</p></div><div><p>求购详情</p><p>'+ num.purchaseDesc+'</p></div><div><p>交货地</p><p>'+ num.deliveryArea + '</p></div><div><p>交易员</p><p>'+ num.adminName +'</p></div><div><p>发布人</p><p>'+ num.userName  +'</p>\</div><div><p>数量</p><p>'+ num.amount +'</p></div>\<div><p>单位</p><p>'+ num.unit +'</p></div></div>')
	
}
function createDivTwo(num){

	$('#content>div').eq(1).append('<p>采购方详情</p><div class="content"><div><p>联系人</p><p><input type="text" disabled="true" value="'+ num.contact +'" /></p></div><div><p>手机号</p><p><input type="text"  disabled="true"  value="'+ num.phone +'" /></p></div><div><p>QQ</p><p><input type="text"   disabled="true" value = "'+ num.qq +'"/></p></div><div><p>微信</p><p><input type="text"  disabled="true" value = "'+ num.weChat+'" /></p></div></div>');
	
}
//跳转的页面
var textVal = '';
$('#footer-nav button').on('click',function(){
	//供货
	//2.1.19
	urlType = '/order/add/withPurchase';
	textVal = $('#textVal').val();
	if(textVal == ''){
		alert("（必填项）供应商信息没有输入")
	}else{
		dataType = "purchaseInfoId=" + detailedId + '&content=' + textVal;
		//这是输入窗内的信息
		console.log(dataType)
		askPostData1(urlType);
	}
})

function askPostData1(num){
	$.ajax({
		url:host + num,
		type:"post",
		data:dataType,
		success:function(res){
			console.log(res)
			if(res.success == true){
//				console.log(res)  没有length
					//res为对象，没有
				window.location.href = 'supplyPopup.html';

			}else{
				//就是无数据则返回什么
				console.log(1)
			}
		}
	});
}
